home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_07_1985_Transactor_Publishing.d64 / tele-tone 64 (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  4KB  |  103 lines

  1. 0 rem the transactor volume 6 issue 02        page 52
  2. 100 rem save"@0:tele-tone 64",8
  3. 105 rem ** rte/85 - synthetic touch tone sounds via the 64's sid chip
  4. 110 :
  5. 115 key=203: num=198: rem ** which key / # chars in keybuf
  6. 120 zp$="000000": rem ** for timed loop later
  7. 125 :
  8. 130 dim pd$(2,3)
  9. 135 pd$(0,0)="697"+"1209": rem 1
  10. 140 pd$(1,0)="697"+"1336": rem 2
  11. 145 pd$(2,0)="697"+"1477": rem 3
  12. 150 pd$(0,1)="770"+"1209": rem 4
  13. 155 pd$(1,1)="770"+"1336": rem 5
  14. 160 pd$(2,1)="770"+"1477": rem 6
  15. 165 pd$(0,2)="852"+"1209": rem 7
  16. 170 pd$(1,2)="852"+"1336": rem 8
  17. 175 pd$(2,2)="852"+"1477": rem 9
  18. 180 pd$(0,3)="941"+"1209": rem #
  19. 185 pd$(1,3)="941"+"1336": rem 0
  20. 190 pd$(2,3)="941"+"1477": rem *
  21. 195 :
  22. 200 xt$(0)="697"+"1633": rem fo - extra
  23. 205 xt$(1)="770"+"1633": rem f  - extra
  24. 210 xt$(2)="852"+"1633": rem i  - extra
  25. 215 xt$(3)="941"+"1633": rem p  - extra
  26. 220 :
  27. 225 dt$="350"+"440": rem dial tone
  28. 230 rg$="440"+"480": rem audible ringing: 2 seconds on, 4 seconds off
  29. 235 lb$="480"+"620": rem line busy: interrupted at  60 int/minute
  30. 240 ro$="480"+"620": rem re-order : interrupted at 120 int/minute
  31. 245 :
  32. 250 sd=54272:    rem start address of sid chip
  33. 255 fc=16.40426: rem frequency multiplying constant
  34. 260 pt=64:       rem voice type: pulse
  35. 265 for i=0 to 24: poke sd+i,0: next: rem initialise sid chip
  36. 270 poke sd+2,0: poke sd+3,8:  rem 50/50 square wave voice #1
  37. 275 poke sd+9,0: poke sd+10,8: rem 50/50 square wave voice #2
  38. 280 poke sd+5,0:    rem attack=0: decay=0 voice #1
  39. 285 poke sd+6,240:  rem sustain=infinite, release=immediate
  40. 290 poke sd+12,0:   rem attack=0: decay=0 voice #2
  41. 295 poke sd+13,240: rem sustain=infinite, release=immediate
  42. 300 poke sd+24,15:  rem set volume to max
  43. 305 :
  44. 310 print chr$(147)chr$(14)"** [212]ouch [212]one 64 **"
  45. 315 print "[208]ress 0-9   [206]ormal [196]ial [212]ones"
  46. 320 print "[208]ress #, *  [211]pecial [198]or [194]usiness"
  47. 325 print "[208]ress a-d   [197]xtra [212]ones [198]o, [198], [201], [208]"
  48. 330 print "[208]ress ([194])   [204]ine [194]usy"
  49. 335 print "[208]ress ([196])   [196]ial [212]one"
  50. 340 print "[208]ress ([207])   [210]e-[207]rder"
  51. 345 print "[208]ress ([210])   [193]udible [210]inging"
  52. 350 print "[208]ress ([211]hift) ([195]lr/[200]ome) [198]or [195]lear"
  53. 355 :
  54. 360 get p$: if p$="" then 360: rem get request
  55. 365 :
  56. 370 sid$="": spec=0: rem init sid string + set condition flag
  57. 375 if p$<"0" or p$>"9" then 395: rem leave room for numeric check
  58. 380 p=val(p$): if p=0 then sid$=pd$(1,3): goto 450
  59. 385 p=p-1: x%=p/3: y=p-3*x%: sid$=pd$(y,x%)
  60. 390 :
  61. 395 if p$="#" then sid$=pd$(0,3)
  62. 400 if p$="*" then sid$=pd$(2,3)
  63. 405 if p$=>"a" and p$<="d" then sid$=xt$(asc(p$)-65)
  64. 410 if p$="[194]" then  sid$=lb$: spec=1: rem busy
  65. 415 if p$="[196]" then  sid$=dt$        : rem dial tone
  66. 420 if p$="[207]" then  sid$=ro$: spec=2: rem re-order
  67. 425 if p$="[210]" then  sid$=rg$: spec=3: rem ringing
  68. 430 if p$=chr$(147) then 310: rem clear the display
  69. 435 if len(sid$)=0 then poke num,0: goto 360: rem wrong key, try again
  70. 440 :
  71. 445 rem ** time to start touch toning **
  72. 450 print p$;
  73. 455 lf=val(mid$(sid$,1,3))*fc: hf=val(mid$(sid$,4))*fc: rem set freq/voice
  74. 460 poke sd+4,pt: poke sd+11,pt: rem gate voice #1 and #2 off
  75. 465 hi%=lf/256: lo=lf-hi%*256:   rem calc lo/hi freq voice #1
  76. 470 poke sd,lo: poke sd+1,hi%:   rem set up freq     voice #1
  77. 475 hi%=hf/256: lo=hf-hi%*256:   rem calc lo/hi freq voice #2
  78. 480 poke sd+7,lo: poke sd+8,hi%: rem set up freq     voice #2
  79. 485 poke sd+4,pt+1: poke sd+11,pt+1: rem gate voice #1 and #2 on
  80. 490 ct=0: ti$=zp$: rem set for timed loop if needed
  81. 495 :
  82. 500 if spec=0 then 570: rem nothing special to do
  83. 505 :
  84. 510 if spec<3 then 530: rem #3 = audible ringing
  85. 515 if ct=0 and ti=>120 then gosub 595: rem flip ct, re-set ti$, gate off
  86. 520 if ct and ti=>240 then gosub 600:   rem flip ct, re-set ti$, gate on
  87. 525 :
  88. 530 if spec<>2 then 550: rem #2 = re-order signal
  89. 535 if ct=0 and ti=>15 then gosub 595
  90. 540 if ct and ti=>15 then gosub 600
  91. 545 :
  92. 550 if spec>1 then 570: rem #1 = busy signal
  93. 555 if ct=0 and ti=>30 then gosub 595
  94. 560 if ct and ti=>30 then gosub 600
  95. 565 :
  96. 570 wch=peek(key): if wch<>64 then 500: rem wait till no key pressed
  97. 575 poke sd+4,pt: poke sd+11,pt: rem gate both voices off
  98. 580 poke sd,0: poke sd+1,0: poke sd+7,0: poke sd+8,0: rem set freq's low
  99. 585 goto 360: rem go for next key press
  100. 590 :
  101. 595 ti$=zp$: ct=not ct: poke sd+4,pt: poke sd+11,pt: return:     rem gate off
  102. 600 ti$=zp$: ct=not ct: poke sd+4,pt+1: poke sd+11,pt+1: return: rem gate on
  103.